package com.test;

import java.net.ServerSocket;
import java.net.Socket;
import java.io.*;

public class Server{
	private ServerSocket ss;
	private Socket socket;
	private InputStream in;
	private PrintWriter out;
	
	public Server(){
		try{
			ss = new ServerSocket(13000);
			while(true){
				byte[] b = new byte[1024];
				socket = ss.accept();
				in = socket.getInputStream();
				out = new PrintWriter(socket.getOutputStream(),true);
				int bytesRead = 0;
				bytesRead = in.read(b, 0, 1024);
				if (bytesRead != -1) {
					System.out.println(new String(b, 0, bytesRead, "gb2312"));
				}
				
				out.print("bye.");
				out.close();
				in.close();
				socket.close();
			}
		}catch (IOException e){
			
		}
	}
	
	public static void main(String[] args){
		new Server();
	}
}
